Repository navigation
feat(broker): PreToolUse enforcers gate-egress + gate-fs (Pillar 3 step 4) - #305
Merged
Merged
Conversation
…ep 4) The first ENFORCED surface of the exec-broker (design: pillar3-exec-broker-5.0.md §3.3): two PreToolUse gates in the gate-bash/gate-env mold that mediate the agent's actual pending tool calls against the SIGNED [scope]/RoE via brokerScope (fail-closed). - broker/extract.ts: pure, conservative network-target extraction — only explicit http(s) URLs (WHATWG-parsed); a bare hostname in a command is ambiguous and never guessed. - kit gate-egress: a pending Bash command's network targets must all be inside the signed [scope].egress. No verified scope (unsigned/tampered/missing) => a wired gate grants NOTHING — all network targets denied with an honest reason. Off-scope => exit 2. - kit gate-fs: a pending Write/Edit must target a path inside the signed [scope].fs (traversal-safe, default project root). Same fail-closed posture. - Every deny leaves a best-effort audit entry (logAuditEvent; a missing .kit.toml or audit backend never changes the verdict — the deny is the safe outcome). Cline stdout-JSON contract supported like the other gates. Unparseable HARNESS envelopes fail open (the model can't shape the envelope; never break the agent on garbage) — the scope decisions themselves stay fail-closed. - Registry entries (experimental) + public-surface regenerated. Tests: 6 pure extraction fixtures + 9 SUBPROCESS integration tests spawning the real compiled CLI with hook payloads on stdin (allow in-scope, exit-2 deny off-scope, deny-all on unsigned/ tampered scope, traversal escape, pass-through for non-network/non-write calls). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
|
✅ Docker image built successfully
|
Merged
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Step 4 of the Pillar 3 exec-broker — the first enforced surface. Two PreToolUse gates in the proven
gate-bash/gate-envmold that mediate the agent's actual pending tool calls against the signed[scope]/RoE viabrokerScope(fail-closed). This is the North Star's advisory→enforced shift made concrete: an autonomous agent's network targets and file writes are now blockable at exec time, gated on a cryptographically attributable RoE.Type of Change
Related Issues
kit-research/docs/research/pillar3-exec-broker-5.0.md§3.3 (kit-research chore: flush dead app-ops + SaaS-scaffold code (~21.6k lines) #30)Changes Made
src/broker/extract.ts— pure, conservative network-target extraction: only explicithttp(s)://URLs (WHATWG-parsed, hostname only). A bare hostname in a command is ambiguous and is never guessed — honest limitation, documented.src/commands/gate.ts:kit gate-egress— a pending Bash command's network targets must all be inside the signed[scope].egress. No verified scope (unsigned / tampered / missing) ⇒ a wired gate grants nothing — all network targets denied with an honest, actionable reason. Off-scope ⇒ exit 2.kit gate-fs— a pending Write/Edit must target a path inside the signed[scope].fs(traversal-safe; default project root). Same fail-closed posture.logAuditEvent; a missing.kit.toml/audit backend never changes the verdict — the deny is the safe outcome). Cline stdout-JSON contract supported like the other gates.src/cli.ts—gate-egress/gate-fsregistry entries (experimental);contracts/public-surface.jsonregenerated.Testing
Test Coverage
npm test) — full suite 2700 pass / 0 fail (2685 baseline + 15)Manual Testing
npx tsc --noEmit→ clean;npx eslint src→ 0 errors.npm run build && node scripts/gen-public-surface.mjs && node scripts/test.mjs→ 2700 pass, 0 fail.Breaking Changes
None / N/A — new opt-in gates; nothing is wired automatically.
Checklist
npm test)Performance Impact
Reviewer Notes
The deliberate asymmetry to review: fail-open on the envelope, fail-closed on the scope. An unparseable stdin envelope is a harness/config artifact (the model cannot shape it), so it must not brick the agent — same posture as
gate-bash/gate-env. But once a network target or file write is identified, the decision is strictly fail-closed: wiring the gate is the opt-in, and without a verified scope it grants nothing.gate-secretis deliberately absent — secret-scoped env belongs at exec time insidewithGovernance(step 5), not in a PreToolUse hook, and a stub here would be false enforcement. Remaining: step 5 (scope step inwithGovernance) + agent-config wiring convenience.🤖 Generated with Claude Code
https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
Generated by Claude Code